
#ifndef __I2C_SOFT_H__
#define __I2C_SOFT_H__
#include "stm32f4xx.h"
#include "systick.h"

// i2c 执行情况 
#define I2C_RESULT_OK            0
#define I2C_ERR_DEVICE_ADDR      1
#define I2C_ERR_REGISTER_ADDR    2
#define I2C_ERR_WRITE            3
#define I2C_ERR_READ             4

//引脚配置
#define I2C_SCL_PORT   GPIOB
#define I2C_SCL_PIN    GPIO_Pin_6
#define I2C_SCL_RCU    RCC_AHB1Periph_GPIOB

#define I2C_SDA_PORT   GPIOB
#define I2C_SDA_PIN    GPIO_Pin_7
#define I2C_SDA_RCU    RCC_AHB1Periph_GPIOB

void i2c_soft_init();
// addr 是硬件地址  内部会自动转换 为写地址和读地址
// data 是数组指针
uint8_t i2c_soft_read(uint8_t addr, uint8_t reg, uint8_t* data, uint32_t len);
uint8_t i2c_soft_write(uint8_t addr, uint8_t reg, uint8_t* data, uint32_t len);
#endif